package com.approval.approvalapp.index.cygn;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.HysUseBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class HysSyjlAdapter extends RecyclerView.Adapter<HysSyjlAdapter.Holder> {

    List<HysUseBean> hysUseBeanList;

    Context context;

    public void setHysUseBeanList(List<HysUseBean> hysUseBeanList) {
        this.hysUseBeanList = hysUseBeanList;
        notifyDataSetChanged();
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(context).inflate(R.layout.item_hyssyjl, parent, false);
        Holder holder = new Holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(Holder holder, final int position) {
            holder.tvName1.setText(hysUseBeanList.get(position).getTitle());
            holder.tvName2.setText(hysUseBeanList.get(position).getM() + "");
            holder.tvName3.setText(hysUseBeanList.get(position).getY() + "");
            holder.xqLl.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(context,HysSyjlxqListActivity.class);
                    intent.putExtra("implacen",hysUseBeanList.get(position).getTitle());
                    context.startActivity(intent);
                }
            });
    }

    @Override
    public int getItemCount() {
        if (hysUseBeanList == null){
            return 0;
        }else {
            return hysUseBeanList.size();
        }
    }

    class Holder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_name1)
        TextView tvName1;
        @Bind(R.id.tv_name2)
        TextView tvName2;
        @Bind(R.id.tv_name3)
        TextView tvName3;
        @Bind(R.id.xq_ll)
        LinearLayout xqLl;
        public Holder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


}
